package hust.ioic.oa.service.impl;



import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import hust.ioic.oa.base.BaseDaoImpl;
import hust.ioic.oa.domain.Comment;
import hust.ioic.oa.service.CommentService;
@Service
@Transactional
@SuppressWarnings("unchecked")
public class CommentServiceImpl extends BaseDaoImpl<Comment> implements CommentService {

	@Override
	public List<Comment> getByFile(Integer rdfileId) {
		// TODO Auto-generated method stub
		return getSession().createQuery("FROM Comment c WHERE c.rdfileId=? order by id desc")
				.setParameter(0,rdfileId)//
				.list();
	}

	@Override
	public void deleteByFile(Integer rdfileId) {
		Query query = getSession().createSQLQuery("delete from z_comment  where rdfileId='" + rdfileId+ "'");
		 query.executeUpdate();
	}



}
